/********************************************************************************
* Name      : Stephen Durfey													*
* Class     : CS202, MWF 9:30am-10:20am											*
* Instructor: Ron Conway														*
* Class Code: 156																*
* File      : assign2.cpp														*
*																				*
* This program is designed to handle a simple employee database using a linked  *
* list. Each employee in the database is stored with the following information: *
* Employee Name, Employee ID number, the department the employee works in, and  *
* the amount of Sales the employee has made. The database will be constructed   *
* with the employees being listed in order, according their respective ID       *
* number.																		*
*																				*
* The program has a few various capabilities to handle the employee data.       *
* New employees can be added or deleted, and the database can be printed out    *
* in either its entirety, or by department code.								*
********************************************************************************/



#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include "storelist.h"

using namespace std;

int main()
{
	int empID, deptNum, command;
	string empName;
	double empSales;
	ifstream inData;
	Employee* passedPtr; //used to hold the address of the newly created node
	StoreList newElem; //the anchor for the list, and used to access all functions in the StoreList class

	inData.open("storedata.txt");

	inData >> command;

	cout << fixed << showpoint << setprecision(2);

	//this while loop will continue to loop until a 5 is entered
	//as the command. until this is encountered it will call upon
	//the various functions as needed to accomplish each command.

	while(command != 5)
	{

		//creates a new node and then passes the address to the insertNode class
		//function and adds it to the linked list.

		if(command == 1)
		{
			inData.ignore();
			getline(inData, empName);
			inData >> empID >> deptNum >> empSales;
			passedPtr = new Employee(empName, empID, deptNum, empSales);

			newElem.insertNode(passedPtr);
		}

		//removes the specified employee by passing the employee ID #
		//read in from the data file, and passes the value to the
		//deleteNode class function.

		else if(command == 2)
		{
			inData >> empID;

			newElem.deleteNode(empID);
		}

		//simply calls upon the printList() class funtion and prints
		//the list in its entirety.

		else if(command == 3)
		{
			newElem.printList();
		}

		//calls upon the printDept() class function by passing the value
		//of the specified department code.

		else if(command == 4)
		{
			inData >> deptNum;

			newElem.printDept(deptNum);
		}

		inData >> command;
	}

	return 0;
}
			


